package com.ihg.hiex.entity.session.during;

import java.beans.Transient;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "session_calibration_competency")
public class SessionCalibrationCompetency {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 名称 */
    private String name;
    
    /** 总评分 */
    @Enumerated(EnumType.STRING)
    private SessionAnchorScoreType score;
    
    /** effective */
    private String effective;
    
    /** inEffective */
    private String inEffective;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private SessionCalibration sessionCalibration;
    
    /** 状态 */
    @Enumerated(EnumType.STRING)
    private SessionCalibrationStatus status;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public SessionCalibrationCompetency() {
    }
    
    /**
     * 
     * @param name
     * @param sessionCalibration
     */
    public SessionCalibrationCompetency(String name, SessionCalibration sessionCalibration) {
        this.name = name;
        this.sessionCalibration = sessionCalibration;
        this.status = SessionCalibrationStatus.EDITING;
        this.disabled = false;
    }
    
    /**
     * 
     * @param score
     * @return
     */
    public SessionCalibrationCompetency edit(SessionAnchorScoreType score) {
        this.score = score;
        return this;
    }
    
    /**
     * 
     * @param status
     * @return
     */
    public SessionCalibrationCompetency changeStatus(SessionCalibrationStatus status) {
        this.status = status;
        return this;
    }
    
    public String getNameAlias() {
        if(this.name.equalsIgnoreCase("Owner Relations")) {
          return "or";
        } else if(this.name.equalsIgnoreCase("Work Collaboratively")) {
          return "wc";
        } else if(this.name.equalsIgnoreCase("Champion Change")) {
          return "cc";
        } else if(this.name.equalsIgnoreCase("Drive Result")) {
          return "dr";
        } else if(this.name.equalsIgnoreCase("Lead And Development")) {
          return "ld";
        } else if(this.name.equalsIgnoreCase("Operations Management")) {
          return "om";
        } else if(this.name.equalsIgnoreCase("Revenue Maximisation")) {
            return "rm";
        } else if(this.name.equalsIgnoreCase("Financial Management")) {
            return "fm";
        } else {
          return null;
        }
      }


    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }
    
    /**
     * Get i18n message key
     * 
     * @return
     */
    @Transient
    public String getMessage() {
        
        String message = null;
        
        switch (this.name) {
            case "Drive Result":
                message = "competency.drive.result";
                break;
            case "Owner Relations":
                message = "competency.owner.relations";
                break;
            case "Champion Change":
                message = "competency.champion.change";
                break;
            case "Lead And Development":
                message = "competency.lead.and.development";
                break;
            case "Work Collaboratively":
                message = "competency.work.collaboratively";
                break;
            case "Financial Management":
                message = "competency.finance.management";
                break;
            case "Operations Management":
                message = "competency.operations.management";
                break;
            case "Revenue Maximisation":
                message = "competency.revenue.maximisation";
                break;
            default:
                break;
        }

        return message;
        
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the score
     */
    public SessionAnchorScoreType getScore() {
        return score;
    }

    /**
     * @return the effective
     */
    public String getEffective() {
        return effective;
    }

    /**
     * @return the inEffective
     */
    public String getInEffective() {
        return inEffective;
    }

    /**
     * @return the sessionCalibration
     */
    public SessionCalibration getSessionCalibration() {
        return sessionCalibration;
    }

    /**
     * @return the status
     */
    public SessionCalibrationStatus getStatus() {
        return status;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param score the score to set
     */
    public void setScore(SessionAnchorScoreType score) {
        this.score = score;
    }

    /**
     * @param effective the effective to set
     */
    public void setEffective(String effective) {
        this.effective = effective;
    }

    /**
     * @param inEffective the inEffective to set
     */
    public void setInEffective(String inEffective) {
        this.inEffective = inEffective;
    }

    /**
     * @param sessionCalibration the sessionCalibration to set
     */
    public void setSessionCalibration(SessionCalibration sessionCalibration) {
        this.sessionCalibration = sessionCalibration;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(SessionCalibrationStatus status) {
        this.status = status;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
